<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {:widget_st('layui','css')}
  {:widget_st('admin','css')}
  {:widget_st('jq','js')}
  {:widget_st('viewer')}
</head>
{:do_action('admin_head')}
<body>

<?php $api_domain = config('version.api_domain'); ?>
<div class="layui-fluid layadmin-cmdlist-fluid detail-body">
    <div style="padding-bottom: 10px;">
      <div>
        {$err_msg|raw}
      </div>
      <?php $t = input('t','');?>
        <a class="layui-btn layui-btn-sm {$t==''?'':'layui-btn-primary'}" href="/admin/Zfyun/store?t">全部</a>
        <a class="layui-btn layui-btn-sm {$t=='插件'?'':'layui-btn-primary'}" href="/admin/Zfyun/store?t=插件">插件</a>
        <a class="layui-btn layui-btn-sm {$t=='模板'?'':'layui-btn-primary'}" href="/admin/Zfyun/store?t=模板">模板</a>
    </div>
  <div class="layui-row layui-col-space30">
      <table class="layui-table">
          <colgroup>
              <col>
          </colgroup>
          <thead>
          <tr>
              <th>插件名</th>
              <th>路径名</th>
              <th>版本</th>
              <th>展示图</th>
              <th>操作</th>
          </tr>
          </thead>
          <tbody>
            <?php foreach($list as $k=>$vo){  ?>
              <tr>
                  <td>
                    插件名:{$vo['title']}<br>
                    作者:{$vo['u_name']}<br>
                    支持站点版本>={$vo['min_site_version']}
                  </td>
                  <td><span class="tan_content">{$vo['plugin_name']}</span></td>
                  <td>
                    本地:{$vo['location']|default=''}<br>
                    商店:{$vo['version_new']}
                  </td>
                  <td>
                    <img src="{$vo['pic']|default=''}" style="width: 100px;height: 50px;"/>
                  </td>
                  <td>
                    <?php if($vo['min_site_version'] > config('version.version')){ ?>
                      系统版本过低
                    <?php }else{ ?>
                      <?php if($vo['location']){ ?>
                        <?php if($vo['version_new']>$vo['location']){ ?>
                        <a href="javascript:;" class="layui-btn layui-btn-sm" onclick="zfAdminShow('升级','{$api_domain}/addons/zf_store_softclientv2.user/soft_site_client.html?soft_id={$vo['soft_id']}&site={$client_config["site"]}&token={$client_config["token"]}&hp={$client_config["http"]}')"> 升级</a><br>
                        
                        <?php } ?>
                        <?php if($vo['type']=='插件'){ ?>
                          <a href="javascript:;" onclick='zfAdminShow("{$vo['plugin_name']}说明","/addons/{$vo["plugin_name"]}.plugin/index")' > 首页</a><br>
                          <a href="javascript:;" onclick='zfAdminShow("{$vo['plugin_name']}说明","/addons/{$vo["plugin_name"]}.plugin/setting")' > 配置</a><br>
                          <a href="javascript:;" onclick='zfAdminShow("{$vo['plugin_name']}说明","/addons/{$vo["plugin_name"]}.plugin/help")' > 说明</a>
                        <?php }elseif($vo['type']=='模板'){ ?>
                          <a href="javascript:;" onclick='zfAdminShow("配置","{:url('/i_admin')}")' > 配置</a><br>
                        <?php } ?>

                      <?php }else{ ?>
                        <a href="javascript:;" class="layui-btn layui-btn-sm" onclick="zfAdminShow('授权','{$api_domain}/addons/zf_store_softclientv2.user/soft_site_client.html?soft_id={$vo['soft_id']}&site={$client_config["site"]}&token={$client_config["token"]}&hp={$client_config["http"]}')"> 授权</a>
                      <?php } ?>
                    <?php } ?>

                  </td>
              </tr>
            <?php }  ?>
          </tbody>
      </table>

  </div>
</div>


  {:widget_st('layui','js')}  
  {:widget_st('common','js')}
  <script>
 layui.use(['layer','upload'], function(){
    var $ = layui.$ 
    ,laypage = layui.laypage
    ,layer = layui.layer
    ,element = layui.element
    ,upload = layui.upload;
  
   
   
   upload.render({
      elem: '#up_file'
      ,accept: 'file' 
      ,url:"{:url('zfyun/plugin_upload')}"
      ,before: function(obj){
          var index = layer.load();
      }
      ,done: function(res){
        layer.closeAll()
        if(res.result==1){
          layer.msg(res.msg, {icon: 1});
          setTimeout(function() {
              location.reload(true);
          }, 3000);
        }else{
          layer.msg(res.msg, {icon: 2});
        }
      }
    });
   
   $('.plugin_uninstall').on('click',function(){
    var plugin_name = $(this).attr('item')
     layer.confirm('确认卸载？', {
        btn: ['卸载','取消']
      }, function(){
        var index = layer.load();
          $.ajax({
            type:'get',
            url:"{:url('zfyun/plugin_uninstall')}",
            data:{plugin_name},
            dataType:'json',
            success:function(res){
              layer.closeAll()
              if(res.result==1){
                layer.msg(res.msg, {icon: 1});
                setTimeout(function() {
                    location.reload(true);
                }, 3000);
              }else{
                layer.msg(res.msg, {icon: 2});
              }
              
            }
          })

      }, function(){
          //取消的操作
      });
   })
   $('.plugin_backup').on('click',function(){
    var plugin_name = $(this).attr('item')
     layer.confirm('确认备份？', {
        btn: ['备份','取消']
      }, function(){
        var index = layer.load();
          $.ajax({
            type:'get',
            url:"{:url('zfyun/plugin_backup')}",
            data:{plugin_name},
            dataType:'json',
            success:function(res){
              layer.closeAll()
              if(res.result==1){
                layer.msg(res.msg, {icon: 1});
                setTimeout(function() {
                    location.reload(true);
                }, 3000);
              }else{
                layer.msg(res.msg, {icon: 2});
              }
              
            }
          })

      }, function(){
          //取消的操作
      });
   })
   

   $('.plugin_upgrade').on('click',function(){
    var plugin_name = $(this).attr('item')
     layer.confirm('确认升级？', {
        btn: ['升级','取消']
      }, function(){
        var index = layer.load();
          $.ajax({
            type:'get',
            url:"{:url('zfyun/plugin_act')}?type=plugin&action=upgrade",
            data:{plugin_name},
            dataType:'json',
            success:function(res){
              layer.closeAll()
              if(res.result==1){
                layer.msg(res.msg, {icon: 1});
                setTimeout(function() {
                    location.reload(true);
                }, 3000);
              }else{
                layer.msg(res.msg, {icon: 2});
              }
              
            }
          })

      }, function(){
          //取消的操作
      });
   })


});
  </script>
</body>
</html>
{:do_action('admin_js')}
<script>$('.detail-body').viewer();</script>